package com.yh.search.controller;

import com.lxw.api.search.EsCourseControllerApi;
import com.lxw.framework.domain.course.CoursePub;
import com.lxw.framework.domain.course.TeachplanMediaPub;
import com.lxw.framework.domain.search.CourseSearchParam;
import com.lxw.framework.exception.CustomException;
import com.lxw.framework.model.response.QueryResponseResult;
import com.yh.search.service.EsSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/search/course")
public class EsCourseController implements EsCourseControllerApi {
    @Autowired
    EsSearchService esSearchService;

    @Override
    @GetMapping(value="/list/{page}/{size}")
    public QueryResponseResult list(@PathVariable int page,@PathVariable  int size, CourseSearchParam courseSearchParam) throws CustomException {

        return esSearchService.list(page,size,courseSearchParam);
    }

    @Override
    @GetMapping("/getall/{id}")//getallall   getallallall
    public Map<String, CoursePub> getall(@PathVariable String id) {
        return esSearchService.getall(id);
    }

    @GetMapping(value="/getmedia/{teachplanId}")
    public TeachplanMediaPub getmedia(@PathVariable("teachplanId") String teachplanId){
        return esSearchService.getmedia(teachplanId);
    }
}
